package com.situ.imall.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName JSONUtil
 * @Description TODO
 * @Author 周轩霆
 * @Date 2022/7/29 11:48
 **/

public class JSONUtil {
    private JSONUtil() {

    }

    public static void toJSON(HttpServletResponse resp, Object obj) {
        resp.setContentType("text/html; charset=UTF-8");
        ObjectMapper mapper = new ObjectMapper();
        try {
            mapper.writeValue(resp.getWriter(), obj);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
